#include<stdio.h>
#include<string.h>
int E_Table[48] = {31,0,1,2,3,4,  
                  3,4,5,6,7,8,  
                  7,8,9,10,11,12,  
                  11,12,13,14,15,16,  
                  15,16,17,18,19,20,  
                  19,20,21,22,23,24,  
                  23,24,25,26,27,28,  
                  27,28,29,30,31,0};
                  
int S1_Table[4][16] =  {
              {14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7},  
              {0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8},  
              {4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0},  
              {15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13}
}; 
int P_Table[32] = {15,6,19,20,28,11,27,16,  
          0,14,22,25,4,17,30,9,  
          1,7,23,13,31,26,2,8,  
          18,12,29,5,21,10,3,24};  
int k1[48]={
	0,0,1,1,1,1,
	0,1,1,0,0,0,
	1,1,1,1,1,1,
	0,0,1,1,0,1,
	0,0,1,1,0,1,
	1,1,0,0,1,1,
	1,1,1,1,0,0,
	0,0,0,1,1,0
};
int R0[32]={
	0,0,0,0,
	0,0,0,0,
	1,1,1,1,
	1,1,1,1,
	0,0,0,0,
	0,1,1,0,
	1,0,0,0,
	0,0,1,1
};
int main(){
int R01[48]={};
int x,y,z;
for(x=1;x<8;x++){
	R01[1+6*x]=R0[0+4*x];
	R01[2+6*x]=R0[1+4*x];
	R01[3+6*x]=R0[2+4*x];
	R01[4+6*x]=R0[3+4*x];
	R01[5+6*(x-1)]=R0[4+4*(x-1)];
	R01[6+6*(x-1)]=R0[3+4*(x-1)];
}R01[0]=R0[31];R01[47]=R0[0];
for(y=0;y<48;y++){
	printf("%d",R01[y]);
}
int i;int y1[48]={};
for(i=0;i<48;i++){
	if(1==R01[i]+k1[i])
	y1[i]=1;
	else
	y1[i]=0;
}
printf("\n");
for(y=0;y<48;y++){
	printf("%d",y1[y]);
}
int d[32]={};
int m;
for(x=0;x<8;x++){
z=0;y=0;m=0;
	if(y1[0+6*x]==1){
		z=z+2;
	}
	if(y1[5+6*x]==1){
		z=z+1;
	}
	if(y1[1+6*x]==1){
		y=y+8;
	}
	if(y1[2+6*x]==1){
		y=y+4;
	}
	if(y1[3+6*x]==1){
		y=y+2;
	}
	if(y1[4+6*x]==1){
		y=y+1;
	}
	m=S1_Table[z][y];
		if(m>=8){
			d[x*4+0]=1;
			m=m-8;
		}
		else
		d[x*4+0]=0;
		if(m>=4){
			d[x*4+1]=1;
			m=m-4;
		}
		else
		d[x*4+1]=0;
		if(m>=2){
			d[x*4+2]=1;
			m=m-2;
		} 
		else
		d[x*4+2]=0;
		if(m>=1){
			d[x*4+3]=1;
		}
		else
		d[x*4+3]=0;
}
printf("\n");
for(y=0;y<32;y++){
	printf("%d",d[y]);
}
int g[32]={};
for(x=0;x<32;x++){
	g[x]=d[P_Table[x]];
}
printf("\n");
for(y=0;y<32;y++){
	printf("%d",g[y]);
}
}